package com.SoilMM.controller;


import com.SoilMM.entity.ShiShangTimeEntity;
import com.SoilMM.service.ShiShangTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.crypto.Data;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Gramorgan
 * @since 2021-07-04
 */
@RestController
@RequestMapping("/shiShangTimeEntity")
public class ShiShangTimeController {
    @Autowired
    private ShiShangTimeService shiShangTimeService;
    @RequestMapping("update")
    public Map<String,Object> update (@RequestBody ShiShangTimeEntity shiShangTimeEntity ) {
        Map<String,Object> resultMap = new HashMap<>();
        shiShangTimeService.updateById(shiShangTimeEntity);
        resultMap.put("code",10000);
        resultMap.put("message","修改成功");
        return resultMap;
    }
    @RequestMapping("save")
    public Map<String,Object> save (@RequestBody ShiShangTimeEntity shiShangTimeEntity ) {
        Map<String,Object> resultMap = new HashMap<>();
//        // time不能为空，需要手动给值
//
//
//        Date date = new Date();
//
//        Timestamp timestamp = new Timestamp (date.getTime()); //2013-01-14 22:45:36.484
//        LocalDateTime localDateTime = new LocalDateTime(timestamp);
//        shiShangTimeEntity.setTime(localDateTime);
        shiShangTimeService.save(shiShangTimeEntity);
        resultMap.put("code",10000);
        resultMap.put("message","新增成功");
        return resultMap;
    }
}

